home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 January - Disc 2 / Macworld (1999-01) (Disk 2).dmg / Serious Demos / Symbolic Composer 4.2 / Environment / Projects / Questions & Answers / Q&A Programming Music / Making Beth tunings < prev    next >
Lisp/Scheme  |  1998-10-26  |  4KB  |  84 lines

  1. MAKING BETH TUNINGS
  2.  
  3. >I have been working out a number of  overtone tonalities based on the
  4. >frequency of 960HZ(scientific scale) =1/1.  For instance the tonality
  5. >n/1 has one tone, 960/960; n/2 has two, 450/960 and 960/960.  I have
  6. >worked out these frequencies to n/70 using the Just Intonation
  7. >calculator, then manually typing the frequencies into my own megatunes
  8. >file.  These is tedious to say the least, since I usually calculate at
  9. >least 60 overtones.   Is there a way I could do this faster in SCOM. 
  10. >Could you write a small program that would do it for me.  I would very
  11. >much appreciate any help with this project.
  12.  
  13. (defun make-beth-scale (base divider n)
  14.    (let (out)
  15.      (dotimes (i n)
  16.        (push (compress (list (roundup (* (1+ i) 
  17.                                       (/ base divider))) '/ base)) out))
  18.      (nreverse out)))
  19.  
  20. (make-beth-scale 960 40 60)
  21. --> (24/960 48/960 72/960 96/960 120/960 144/960 168/960 192/960 216/960 
  22. 240/960 264/960 288/960 312/960 336/960 360/960 384/960 408/960 432/960 
  23. 456/960 480/960 504/960 528/960 552/960 576/960 600/960 624/960 648/960 
  24. 672/960 696/960 720/960 744/960 768/960 792/960 816/960 840/960 864/960 
  25. 888/960 912/960 936/960 960/960 984/960 1008/960 1032/960 1056/960 1080/960 
  26. 1104/960 1128/960 1152/960 1176/960 1200/960 1224/960 1248/960 1272/960 
  27. 1296/960 1320/960 1344/960 1368/960 1392/960 1416/960 1440/960)
  28.  
  29. defining tonality
  30.  
  31. (create-tonality n/40 (make-beth-scale 960 40 60))
  32.  
  33. using n/40
  34.  
  35. (activate-tonality (n/40 c 4 1000))
  36.  
  37. (make-beth-scale 960 23 60)
  38. --> (42/960 83/960 125/960 167/960 209/960 250/960 292/960 334/960 376/960 
  39. 417/960 459/960 501/960 543/960 584/960 626/960 668/960 710/960 751/960 
  40. 793/960 835/960 877/960 918/960 960/960 1002/960 1043/960 1085/960 1127/960 
  41. 1169/960 1210/960 1252/960 1294/960 1336/960 1377/960 1419/960 1461/960 
  42. 1503/960 1544/960 1586/960 1628/960 1670/960 1711/960 1753/960 1795/960 
  43. 1837/960 1878/960 1920/960 1962/960 2003/960 2045/960 2087/960 2129/960 
  44. 2170/960 2212/960 2254/960 2296/960 2337/960 2379/960 2421/960 2463/960 
  45. 2504/960))
  46.  
  47. Here is a version which finds the most pretty m/n ratio.
  48.  
  49. (defun make-beth-scale2 (base divider n)
  50.    (let (out ratio)
  51.      (dotimes (i n)
  52.        (setq ratio (rationalize (/ (roundup (* (1+ i) (/ base divider))) base)))
  53.        (if (integerp ratio)
  54.          (push (compress (list ratio '/ 1)) out)
  55.          (push ratio out)))
  56.      (nreverse out)))
  57.  
  58. (make-beth-scale2 960 23 60)
  59. --> (7/160 83/960 25/192 167/960 209/960 25/96 73/240 167/480 47/120 139/320 
  60. 153/320 167/320 181/320 73/120 313/480 167/240 71/96 751/960 793/960 167/192 
  61. 877/960 153/160 1 167/160 1043/960 217/192 1127/960 1169/960 121/96 313/240 
  62. 647/480 167/120 459/320 473/320 487/320 501/320 193/120 793/480 407/240 167/96 
  63. 1711/960 1753/960 359/192 1837/960 313/160 2 327/160 2003/960 409/192 2087/960 
  64. 2129/960 217/96 553/240 1127/480 287/120 779/320 793/320 807/320 821/320 313/120)
  65.  
  66. Here is a version that has no rounding errors and it returns the most pretty
  67. ratios.
  68.  
  69. (defun make-beth-scale3 (base divider n)
  70.    (let (out ratio)
  71.      (dotimes (i n)
  72.        (setq ratio (rationalize (/ (* (1+ i) (/ base divider)) base)))
  73.        (if (integerp ratio)
  74.          (push (compress (list ratio '/ 1)) out)
  75.          (push ratio out)))
  76.      (nreverse out)))
  77.  
  78. (make-beth-scale3 960 21 60)
  79. --> (1/21 2/21 1/7 4/21 5/21 2/7 1/3 8/21 3/7 10/21 11/21 4/7 13/21 2/3 5/7 16/21 
  80. 17/21 6/7 19/21 20/21 1/1 22/21 23/21 8/7 25/21 26/21 9/7 4/3 29/21 10/7 31/21 32/21 
  81. 11/7 34/21 5/3 12/7 37/21 38/21 13/7 40/21 41/21 2/1 43/21 44/21 15/7 46/21 47/21 
  82. 16/7 7/3 50/21 17/7 52/21 53/21 18/7 55/21 8/3 19/7 58/21 59/21 20/7)
  83.  
  84.